package com.epower.dao.epowerwordforday.impl;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ali.luna.commons.dao.BaseDAOImpl;
import com.epower.dao.epowerwordforday.EpowerWordForDayDAO;
import com.epower.dataobject.EpowerWordForDayDO;

import java.util.Date;
import java.util.List;

/***
 * DAO实现层
 * 
 * @author QuickDev
 */
@Scope("singleton")
@Component("epowerWordForDayDAO")
public class EpowerWordForDayDAOImpl extends BaseDAOImpl implements EpowerWordForDayDAO {

    /***
     * 查询单个对象
     */
    @Override
    public EpowerWordForDayDO getEpowerWordForDayByOption(EpowerWordForDayDO epowerWordForDay) {
        return (EpowerWordForDayDO) getSqlMapClientTemplate().queryForObject("EpowerWordForDayDAOImpl.GET-EPOWERWORDFORDAY-BY-OPTION", epowerWordForDay);
    }

    /***
     * 查询对象列表
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<EpowerWordForDayDO> getEpowerWordForDayListByOption(EpowerWordForDayDO epowerWordForDay) {
        return (List<EpowerWordForDayDO>) getSqlMapClientTemplate().queryForList("EpowerWordForDayDAOImpl.GET-EPOWERWORDFORDAYList-BY-OPTION", epowerWordForDay);
    }

    /***
     * 根据id查询对象
     */
    @Override
    public EpowerWordForDayDO getEpowerWordForDayById(Integer id) {
        return (EpowerWordForDayDO) getSqlMapClientTemplate().queryForObject("EpowerWordForDayDAOImpl.GET-EPOWERWORDFORDAY-BY-ID", id);
    }

    /***
     * 删除操作
     */
    @Override
    public boolean deleteEpowerWordForDayById(Integer id) {
        int num = getSqlMapClientTemplate().update("EpowerWordForDayDAOImpl.DELETE-EPOWERWORDFORDAY-BY-ID", id);
        return num == 0 ? false : true;
    }

    /***
     * 查询数量
     */
    @Override
    public Integer getEpowerWordForDayCountByOption(EpowerWordForDayDO epowerWordForDay) {
        return (Integer) getSqlMapClientTemplate().queryForObject("EpowerWordForDayDAOImpl.GET-EPOWERWORDFORDAY-COUNT-BY-OPTION", epowerWordForDay);
    }

    /***
     * 更新操作
     */
    @Override
    public boolean updateEpowerWordForDayByOption(EpowerWordForDayDO epowerWordForDay) {
        int num = getSqlMapClientTemplate().update("EpowerWordForDayDAOImpl.UPDATE-EPOWERWORDFORDAY-BY-OPTION", epowerWordForDay);
        return num == 0 ? false : true;
    }

    /***
     * 添加操作
     * 
     * @param
     * @return
     */
    @Override
    public Integer addEpowerWordForDay(EpowerWordForDayDO epowerWordForDay) {
        return (Integer) getSqlMapClientTemplate().insert("EpowerWordForDayDAOImpl.ADD-EPOWERWORDFORDAY", epowerWordForDay);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<EpowerWordForDayDO> getMainEpowerWordForDayBySpelling(String spelling) {
        return getSqlMapClientTemplate().queryForList("EpowerWordForDayDAOImpl.GET-MainEPOWERWORDFORDAY-BY-SPELLING", spelling);
    }

	@SuppressWarnings("unchecked")
	@Override
	public List<EpowerWordForDayDO> queryEpowerMainWordBySpelling(String spelling) {
        return (List<EpowerWordForDayDO>) getSqlMapClientTemplate().queryForList("EpowerWordForDayDAOImpl.queryEpowerMainWordBySpelling", spelling);
 	}

	@SuppressWarnings("unchecked")
	@Override
	public EpowerWordForDayDO getEpowerMainWordByDate(Date date) {
		return (EpowerWordForDayDO) getSqlMapClientTemplate().queryForObject("EpowerWordForDayDAOImpl.queryEpowerWordByDate", date);
	}

	@Override
	public List<EpowerWordForDayDO> queryEpowerMainWordByGroupid(int groupid) {
		return getSqlMapClientTemplate().queryForList("EpowerWordForDayDAOImpl.queryEpowerWordByGroupid", groupid);
	}

}